﻿namespace HRM.CORE
{

    using APP.HELPER.Data.Helper;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;

    public class HRM_INSURANCE_PROCESS
    {
        private string m_Description;
        private string m_EmployeeCode;
        private decimal m_Foundation;
        private DateTime m_FromDate;
        private double m_HealthInsurance;
        private Guid m_ProcessID;
        private double m_SocialInsurance;
        private DateTime m_ToDate;

        public HRM_INSURANCE_PROCESS()
        {
            this.m_ProcessID = Guid.Empty;
            this.m_EmployeeCode = "";
            this.m_FromDate = DateTime.Now;
            this.m_ToDate = DateTime.Now;
            this.m_Description = "";
            this.m_Foundation = 0M;
            this.m_SocialInsurance = 0.0;
            this.m_HealthInsurance = 0.0;
        }

        public HRM_INSURANCE_PROCESS(Guid ProcessID, string EmployeeCode, DateTime FromDate, DateTime ToDate, string Description, decimal Foundation, double SocialInsurance, double HealthInsurance)
        {
            this.m_ProcessID = ProcessID;
            this.m_EmployeeCode = EmployeeCode;
            this.m_FromDate = FromDate;
            this.m_ToDate = ToDate;
            this.m_Description = Description;
            this.m_Foundation = Foundation;
            this.m_SocialInsurance = SocialInsurance;
            this.m_HealthInsurance = HealthInsurance;
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@ProcessID" };
            object[] myValues = new object[] { this.m_ProcessID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_INSURANCE_PROCESS_Delete", myParams, myValues);
        }

        public string Delete(Guid ProcessID)
        {
            string[] myParams = new string[] { "@ProcessID" };
            object[] myValues = new object[] { ProcessID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_INSURANCE_PROCESS_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, Guid ProcessID)
        {
            string[] myParams = new string[] { "@ProcessID" };
            object[] myValues = new object[] { ProcessID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_INSURANCE_PROCESS_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, Guid ProcessID)
        {
            string[] myParams = new string[] { "@ProcessID" };
            object[] myValues = new object[] { ProcessID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_INSURANCE_PROCESS_Delete", myParams, myValues);
        }

        public string DeleteAll(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_INSURANCE_PROCESS_DeleteAll", myParams, myValues);
        }

        public bool Exist(Guid ProcessID)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@ProcessID" };
            object[] myValues = new object[] { ProcessID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_INSURANCE_PROCESS_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(Guid ProcessID)
        {
            string str = "";
            string[] myParams = new string[] { "@ProcessID" };
            object[] myValues = new object[] { ProcessID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_INSURANCE_PROCESS_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_ProcessID = reader.GetGuid(reader.GetOrdinal("ProcessID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_FromDate = Convert.ToDateTime(reader["FromDate"]);
                    this.m_ToDate = Convert.ToDateTime(reader["ToDate"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_Foundation = Convert.ToDecimal(reader["Foundation"]);
                    this.m_SocialInsurance = Convert.ToDouble(reader["SocialInsurance"]);
                    this.m_HealthInsurance = Convert.ToDouble(reader["HealthInsurance"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, Guid ProcessID)
        {
            string str = "";
            string[] myParams = new string[] { "@ProcessID" };
            object[] myValues = new object[] { ProcessID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_INSURANCE_PROCESS_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_ProcessID = reader.GetGuid(reader.GetOrdinal("ProcessID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_FromDate = Convert.ToDateTime(reader["FromDate"]);
                    this.m_ToDate = Convert.ToDateTime(reader["ToDate"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_Foundation = Convert.ToDecimal(reader["Foundation"]);
                    this.m_SocialInsurance = Convert.ToDouble(reader["SocialInsurance"]);
                    this.m_HealthInsurance = Convert.ToDouble(reader["HealthInsurance"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, Guid ProcessID)
        {
            string str = "";
            string[] myParams = new string[] { "@ProcessID" };
            object[] myValues = new object[] { ProcessID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_INSURANCE_PROCESS_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_ProcessID = reader.GetGuid(reader.GetOrdinal("ProcessID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_FromDate = Convert.ToDateTime(reader["FromDate"]);
                    this.m_ToDate = Convert.ToDateTime(reader["ToDate"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_Foundation = Convert.ToDecimal(reader["Foundation"]);
                    this.m_SocialInsurance = Convert.ToDouble(reader["SocialInsurance"]);
                    this.m_HealthInsurance = Convert.ToDouble(reader["HealthInsurance"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_INSURANCE_PROCESS_GetList");
        }

        public DataTable GetList(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_INSURANCE_PROCESS_GetListByEmployee", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("HRM_INSURANCE_PROCESS", "ProcessID", "CV");
        }

        public string Update()
        {
            string[] myParams = new string[] { "@ProcessID", "@EmployeeCode", "@FromDate", "@ToDate", "@Description", "@Foundation", "@SocialInsurance", "@HealthInsurance" };
            object[] myValues = new object[] { this.m_ProcessID, this.m_EmployeeCode, this.m_FromDate, this.m_ToDate, this.m_Description, this.m_Foundation, this.m_SocialInsurance, this.m_HealthInsurance };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_INSURANCE_PROCESS_Update", myParams, myValues);
        }

        public string Update(Guid ProcessID, string EmployeeCode, DateTime FromDate, DateTime ToDate, string Description, decimal Foundation, double SocialInsurance, double HealthInsurance)
        {
            string[] myParams = new string[] { "@ProcessID", "@EmployeeCode", "@FromDate", "@ToDate", "@Description", "@Foundation", "@SocialInsurance", "@HealthInsurance" };
            object[] myValues = new object[] { ProcessID, EmployeeCode, FromDate, ToDate, Description, Foundation, SocialInsurance, HealthInsurance };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_INSURANCE_PROCESS_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, Guid ProcessID, string EmployeeCode, DateTime FromDate, DateTime ToDate, string Description, decimal Foundation, double SocialInsurance, double HealthInsurance)
        {
            string[] myParams = new string[] { "@ProcessID", "@EmployeeCode", "@FromDate", "@ToDate", "@Description", "@Foundation", "@SocialInsurance", "@HealthInsurance" };
            object[] myValues = new object[] { ProcessID, EmployeeCode, FromDate, ToDate, Description, Foundation, SocialInsurance, HealthInsurance };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_INSURANCE_PROCESS_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, Guid ProcessID, string EmployeeCode, DateTime FromDate, DateTime ToDate, string Description, decimal Foundation, double SocialInsurance, double HealthInsurance)
        {
            string[] myParams = new string[] { "@ProcessID", "@EmployeeCode", "@FromDate", "@ToDate", "@Description", "@Foundation", "@SocialInsurance", "@HealthInsurance" };
            object[] myValues = new object[] { ProcessID, EmployeeCode, FromDate, ToDate, Description, Foundation, SocialInsurance, HealthInsurance };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_INSURANCE_PROCESS_Update", myParams, myValues);
        }

        [DisplayName("Description"), Category("Column")]
        public string Description
        {
            get
            {
                return this.m_Description;
            }
            set
            {
                this.m_Description = value;
            }
        }

        [DisplayName("EmployeeCode"), Category("Column")]
        public string EmployeeCode
        {
            get
            {
                return this.m_EmployeeCode;
            }
            set
            {
                this.m_EmployeeCode = value;
            }
        }

        [DisplayName("Foundation"), Category("Column")]
        public decimal Foundation
        {
            get
            {
                return this.m_Foundation;
            }
            set
            {
                this.m_Foundation = value;
            }
        }

        [Category("Column"), DisplayName("FromDate")]
        public DateTime FromDate
        {
            get
            {
                return this.m_FromDate;
            }
            set
            {
                this.m_FromDate = value;
            }
        }

        [DisplayName("HealthInsurance"), Category("Column")]
        public double HealthInsurance
        {
            get
            {
                return this.m_HealthInsurance;
            }
            set
            {
                this.m_HealthInsurance = value;
            }
        }

        [Category("Primary Key"), DisplayName("ProcessID")]
        public Guid ProcessID
        {
            get
            {
                return this.m_ProcessID;
            }
            set
            {
                this.m_ProcessID = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class HRM_INSURANCE_PROCESS";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        [DisplayName("SocialInsurance"), Category("Column")]
        public double SocialInsurance
        {
            get
            {
                return this.m_SocialInsurance;
            }
            set
            {
                this.m_SocialInsurance = value;
            }
        }

        [DisplayName("ToDate"), Category("Column")]
        public DateTime ToDate
        {
            get
            {
                return this.m_ToDate;
            }
            set
            {
                this.m_ToDate = value;
            }
        }
    }
}

